//
// Created by PC on 2023/12/21.
//
#include <iostream>

using namespace std;

struct Node
{
    int value;
    struct Node *right;
};

Node * reverse(Node *head)
{
    Node *pre = NULL;
    Node *next = NULL;
    while(head!=NULL)
    {
        next = head->right;
        head->right=pre;
        pre = head;
        head=next;
    }
    return pre;

}
void printL(Node *head)
{
    Node *cur = head;
    while(cur)
    {
        printf("%d\n",cur->value);
        cur=cur->right;
    }
}

int main()
{
    Node n1;
    Node n2;
    Node n3;
    n1 = {1, &n2};
    n2 = {2, &n3};
    n3 = {3, NULL};

    Node *head = &n1;
    head=reverse(head);
    printL(head);
}
